var Maze = function(){};

Maze.buildAndReturnContext = function( timeline ) {

	var location = timeline.createEmptyMovieClip( "location" , 1 );

	location._y = 24;

	location.attachMovie ( "labyrinth" , "labyrinth" , 0 );

	var depth = 1;

	var dots = this.dots = [];

	for ( var y in map ) {

		var row = map[y];

		for ( var x in row ) {

			switch ( row[x] ) {

				case 4:

					var dot = location.attachMovie ( "dot" , "dot_" + depth , depth++ , { _x: Number( x ) * 8 , _y: Number( y ) * 8 } );

					if ( dots[ y ] == undefined ) dots[y] = [];

					dots[y][x] = dot;

					break;

				case 8:

					var dot = location.attachMovie ( "switcher" , "dot_" + depth , depth++ , { _x: Number( x ) * 8 , _y: Number( y ) * 8 } );

					if ( dots[ y ] == undefined ) dots[y] = [];

					dots[y][x] = dot;

					break;

			}

		}

	}

	// return mazeContext //

	return { depth: depth, location: location, dots: dots };

}